package com.mnf.server.component;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

public class MusicHttpServerTest {

	public static void main(String[] args) throws Exception {
		MusicHttpServer musicHttpServer = new MusicHttpServer("127.0.0.1", 80) {
			@Override
			protected void onPlay(boolean play) {
				if (play) {
					System.err.println("I am music player, I am playing music now!!!");					
				}
			}
			
			@Override
			protected void handlePlayResponse(boolean play,
					HttpServletResponse httpResponse) throws IOException {
				httpResponse.setContentType("text/html;charset=utf-8");
				httpResponse.setStatus(HttpServletResponse.SC_OK);
				httpResponse.getWriter().println("<h1>Music server is playing music now!!!</h1>");
			}
		};
		
		musicHttpServer.start();
		
		// Test server by go to the url: http://localhost/command?play=1 in any browser!
		
	}

}
